<template>
  <ul class="tab-bar">
    <li
      v-for="route in tabRoutes"
      :key="route.path"
      @click="jump(route.path)"
    >
      <i class="iconfont" v-html="route.meta.icon"></i>
      <span>{{ route.meta.title }}</span>
    </li>
  </ul>
</template>

<script>
import routes from '@/router/routes'

export default {
  name: 'TabBar',

  computed: {
    tabRoutes () {
      // return routes.filter(route => route.meta && route.meta.isTab)
      return routes.filter(route => route.meta?.isTab)
    }
  },

  methods: {
    jump (path) {
      this.$router.push(path)
    }
  }
}
</script>

<style lang="less">
@font-face {
  font-family: 'iconfont';  /* project id 2421900 */
  src: url('//at.alicdn.com/t/font_2421900_3ss6hvx8zb3.eot');
  src: url('//at.alicdn.com/t/font_2421900_3ss6hvx8zb3.eot?#iefix') format('embedded-opentype'),
  url('//at.alicdn.com/t/font_2421900_3ss6hvx8zb3.woff2') format('woff2'),
  url('//at.alicdn.com/t/font_2421900_3ss6hvx8zb3.woff') format('woff'),
  url('//at.alicdn.com/t/font_2421900_3ss6hvx8zb3.ttf') format('truetype'),
  url('//at.alicdn.com/t/font_2421900_3ss6hvx8zb3.svg#iconfont') format('svg');
}

.iconfont{
  font-family:"iconfont" !important;
  font-size:16px;font-style:normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
}

.tab-bar {
  display: flex;
  border-top: 1px solid #eaeaea;
  position: fixed;
  bottom: 0;
  width: 100%;
  background: #fff;

  li {
    flex: 1;
    height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;

    i {
      font-size: 20px;
    }

    &.active {
      color: rgb(91,179,99);
      font-weight: 700;
    }
    span{
      font-size: 14px;
    }
  }
}
</style>
